<?php
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>Supermarket</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="style.css" type="text/css" />
</head>

<body>

<div id="container" class="clearfix">

    <h1>HEMART B10<em> CABANG<?php echo " $_SESSION[namacabang]";?></em></h1>
	<h2></h2>

 <div id="content">

		<h3>Daftar Cabang</h3>
		<br/>

        <?php

		$dbconn = pg_connect ("host=localhost port=5432 dbname=postgres user=postgres password=leliput93");
		if (!$dbconn) {
		  echo "An error occured.\n";
		  exit;
		}

		$result = pg_query($dbconn, "SELECT c.nama, c.alamat, c.no_telepon, c.tgl_buka, count (p.no_urut_pegawai)
									 FROM supermarket.cabang c, supermarket.pegawai p
									 WHERE p.kode_cabang = c.kode
									 GROUP BY c.nama, c.alamat, c.no_telepon, c.tgl_buka, c.kode");
		if (!$result) {
		  echo "An error occured.\n";
		  exit;
		}

		echo "<table>
		<th>Nama Cabang</th>
		<th>Alamat</th>
		<th>Nomor Telepon</th>
		<th>Tanggal Buka</th>
		<th>Jumlah Pegawai</th>";


		for ( $counter = 0; $row = pg_fetch_row( $result ); $counter++ )
		{
			// build table to display results
			print( "<tr>" );

			foreach ( $row as $key => $value )
			print( "<td>$value</td>" );

			print( "</tr>" );
		} // end for

		echo "</table>";

		?>

		</div>

			<ul id="nav">
				<li><a href="login_success.php">Home</a></li>
				<?php
					if ($_SESSION['jabatan'] == 'Admin')
					echo "<li><a href='form_akun.php'>Buat akun</a></li>";
				?>
				<li><a href="q1.php">List Daftar Cabang</a></li>
				<?php
					if ($_SESSION['jabatan'] == 'Manajer Operasional')
					echo "<li><a href='pencatatan1.php'>Pencatatan Transaksi Pembelian</a></li>";
				?>
				<li><a href="daftar_transaksi1.php">Daftar Transaksi Pemasok</a></li>
				<li><a href="rekapitulasi1.php">Rekapitulasi Transaksi Pembelian</a></li>
				<li><a href="produk_terlaku.php" >Daftar Produk Terlaku</a></li>
				<li><a href="B10.php" title="View B10 info">About us</a></li>
				<li><a href="logout.php">Logout</a></li>
			</ul>

		</div>

		<address>
			&copy; 2008 All Rights Reserved. Designed by <a href="http://www.caddoo.net" title="Portfolio of Matthew Caddoo">Matthew Caddoo</a> for <a href="http://www.zymic.com" title="Zymic Free Templates">Zymic</a> <a href="http://www.zymic.com/free-templates">Free Templates</a>. <a href="http://www.zymic.com/free-web-hosting/">Free Web Hosting</a>.
		</address>

</body>
</html>
